package work.base.data.basetype;

import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

/**
 * 字符编码
 */
public class BaseTypeMain {

    public static void main(String[] args) throws UnsupportedEncodingException {
        char aa = 'B';
        byte a = (byte) (aa - 'A');
        System.out.println(a);
        String str = "我";
        byte[] bytes = str.getBytes();
        byte[] bytes1 = "i".getBytes();
        System.out.println(Arrays.toString(bytes1));
        System.out.println(Charset.defaultCharset());

        byte[] b_gbk = str.getBytes("GBK");
        byte[] b_utf8 = str.getBytes(StandardCharsets.UTF_8);
        byte[] b_iso88591 = str.getBytes("ISO8859-1");
        byte[] b_unicode = str.getBytes("unicode");
        System.out.println(Arrays.toString(b_gbk));
        System.out.println(Arrays.toString(b_utf8));
        System.out.println(Arrays.toString(b_iso88591));
        System.out.println(Arrays.toString(b_unicode));
    }
}
